#ifndef _INPUTS_H_
#define _INPUTS_H_


/**************************************************************************************/
#define AD_0_C              3975
#define AD_MAX_C            872
#define AD_TOTAL_N          129


#define CAP_ON_AD           2457     //熄火电容9v以上  ((9v/3) * 4095)/5v = 2457
 

#define DOOR_OPEN           1
#define DOOR_CLOSE          0

#define KNOB_OPEN           1
#define KNOB_CLOSE          0

#define BOX_OPEN           1
#define BOX_CLOSE          0

#define POT_IN              1
#define POT_NO              0
/**************************************************************************************/
#define KNOB1_INPIN         GPIO_Pin_A29     //左微动开关状态
#define KNOB2_INPIN         GPIO_Pin_A27     //右微动开关状态

#define WATER_BOX_INPIN     GPIO_Pin_A26     //水箱开关
#define DOORSTEM_INPIN      GPIO_Pin_A18     //门开关状态
#define DOORBAKE_INPIN      GPIO_Pin_A16     //门开关状态

#define POT_INPIN           GPIO_Pin_A7     //有锅无锅状态

#define BOARD_INPIN         GPIO_Pin_A9     //翻板电流

#define WALL1AD_INPIN       GPIO_Pin_A5     //左防火墙温度采样输入
#define WALL2AD_INPIN       GPIO_Pin_A6     //右防火墙温度采样输入

#define BOX_TEMPR_INPIN         GPIO_Pin_A1     
#define BOM_TEMPR_INPIN         GPIO_Pin_A2         
#define TOP_TEMPR_INPIN         GPIO_Pin_A3  

#define ADJUST1_BOM_PIN         GPIO_Pin_A25
#define ADJUST2_BOM_PIN         GPIO_Pin_A17
#define LEAK_PIN                GPIO_Pin_B9

#define RDOR_INPIN              GPIO_Pin_B6
#define RDOL_INPIN              GPIO_Pin_B7     
#define FGS1_INPIN              GPIO_Pin_A8
#define FGS2_INPIN              GPIO_Pin_A7 //防干烧开关
#define BOARD_INPIN             GPIO_Pin_A9 //翻板电流
#define CURRENT_INPIN           GPIO_Pin_A4


#define THCP1_CH            2
#define THCP2_CH            1
#define BOARD_CH            15
#define WALL1AD_CH          11
#define WALL2AD_CH          12

#define ZBOX_TEMPR_CH        7
#define ZBOM_TEMPR_CH        8
#define KTOP_TEMPR_CH        9

#define FGS1_CH             14
#define FGS2_CH             13
#define TUBE_CURRENT_CH     10

#define TSAMPLE_N           25 //防火墙

#define BROTH_N             90//煲汤检测
/**************************************************************************************/
typedef struct
{
    u8  sta;
    u8  chg_on_f;
    u8  chg_off_f;
} InputSta_t;

typedef struct
{
    u16 disp;  //显示数据
    u16 cur; //实际数据

} TEMPR_t;

typedef struct
{
  u8 tempr;
  u8 temper_ct;
  u8 fireup_delay;
  u8 sure_tmr;

  u8 preTempr; //备用防火墙 用于判断温度上升速度
  u8 upSpeed; //上升速度
  u8 wall_up_speed_ct;
  u8 speed_tmr;
  u8 errTempr;
  u8 temperarr[35];
  u8 arrct;

  u8 on_f;
  u8 start_f;  
} Wall_t;
typedef struct
{
  u16 tempr;
  u16 pretempr;
  u16 diptempr;
  u8 rise_ct;
  u8 error;
  u8 cdly;
  u16 etemper1;
  u16 etemper2;

}GanS_t;
typedef struct
{
  u8 keepwarm_f;
  u8 lowfire_f; 
  u8 soupwork_f;
}Boil_t;
extern InputSta_t   knobl;
extern InputSta_t   knobr;

extern InputSta_t   door;
extern InputSta_t   doorbake;
extern InputSta_t   waterbox;
extern InputSta_t   potstate;

extern TEMPR_t			tempr_box;  //箱体下温度
extern TEMPR_t			tempr_bom;	//底盘温度
extern TEMPR_t			tempr_top;	//箱体上温度（加热膜）

extern bool zero_flag; //电源状态     1：过零
extern bool gb_outfireoff;


extern u8 tempr_wall_L; //防火墙温度
extern u8 tempr_wall_R; //
extern Wall_t  wall_L,wall_R;
extern bool shell_err_f;
extern u16  fire_L_thcp_ad;
extern u16  fire_R_thcp_ad;
extern GanS_t      gans_L;//gans_L,
extern Boil_t      boli;
extern u8 boxerr_cnt;
extern u8 toperr_cnt;
extern u8 bomerr_cnt;
extern u8 gans_errcnt;
extern u8 leak_checkdly;
/**************************************************************************************/
void init_all_inputs(void);
void update_all_inputs(void);
u16 get_average_ad(u8 ch);
void update_doorbake_state(void);
void update_gans1_tempr(void);
void ganstemperdisp(void);
bool temper_errcheck(u8 *errcnt, u16 temper);
void makesoup(void);

#endif
